package com.lili.price;

/**
 * @Auther: 李 力
 * @Date: 2024/8/24
 * @Description: PACKAGE_NAME
 * @version: 1.0
 */
public class LeetCode122 {
    public static int maxProfit(int[] prices) {
        int i = 0;
        int j = 1;
        int sum = 0;
        while (j < prices.length) {
            if (prices[j] - prices[i] > 0) {
                sum += prices[j] - prices[i];
            }
            i++;
            j++;
        }
        return sum;
    }
}
